Skip to content

Fix CA2022 warnings: avoid inexact Stream.Read calls#2009

Open
tyrielv wants to merge 1 commit into
microsoft:masterfrom
tyrielv:tyrielv/fix-inexact-read-warnings
Open

Fix CA2022 warnings: avoid inexact Stream.Read calls#2009
tyrielv wants to merge 1 commit into
microsoft:masterfrom
tyrielv:tyrielv/fix-inexact-read-warnings

Conversation

@tyrielv
Copy link
Copy Markdown
Contributor

@tyrielv tyrielv commented Jun 4, 2026

Replace Stream.Read with Stream.ReadExactly where the caller expects all requested bytes (GitRepo, EnlistmentHydrationSummary, ReusableMemoryStream). Suppress CA2022 in GitIndexParser.ReadNextPage where partial last-page reads are intentional.

Changes (4 files):

  • GitRepo.cs — header read must be exact 5 bytes
  • EnlistmentHydrationSummary.cs — index entry count is exact 4 bytes
  • ReusableMemoryStream.cs — mock helper reads exact length
  • GitIndexProjection.GitIndexParser.cs — pragma suppression; last page of paged index read is intentionally partial

Validation: 0 warnings, 0 errors. 807/807 unit tests pass.

Replace Stream.Read with Stream.ReadExactly where the caller expects
all requested bytes (GitRepo, EnlistmentHydrationSummary, ReusableMemoryStream).
Suppress CA2022 in GitIndexParser.ReadNextPage where partial last-page
reads are intentional.

Assisted-by: Claude Opus 4.6
Signed-off-by: Tyrie Vella <tyrielv@gmail.com>
@tyrielv tyrielv marked this pull request as ready for review June 4, 2026 21:37
@tyrielv tyrielv enabled auto-merge June 4, 2026 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant